﻿/// <reference path="../Core.ts" />

module Supernova {

    export class StarSystem {

        public code: number = 0;
        public name: string = 'Unnamed';
        public bodies: Array<Body> = [new Body(this, BodyType.star)];
        public x: number = 0;
        public y: number = 0;
        public owner: OwnerType = OwnerType.none;
        public population: number = 0;
        public maxPopulation: number = 0;
        public habitable: boolean = false;
        public terraformable: boolean = false;
        public discovered: boolean = false;

        calculatePopulation(): number {
            var population = 0;
            for (var i = 0; i < this.bodies.length; i++) {
                population += this.bodies[i].population;
            }
            return population;
        }

        depopulate() {
            for (var i = 0; i < this.bodies.length; i++) {
                this.bodies[i].depopulate();
            }
            this.population = 0;
            this.owner = OwnerType.none;
        }

    }

}